package main;

import gui.Ventana_Ppal;

import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import logica.Centro_de_Mensajes;
import logica.Configuracion;

import org.pushingpixels.substance.api.skin.SubstanceBusinessBlueSteelLookAndFeel;

import red.ClientKeepAliveSocket;
import splash.SpScreen;

public class MainChacra {

	private Centro_de_Mensajes centro      = null;
	private ClientKeepAliveSocket ka_sock  = null;

	public MainChacra() {
		Configuracion.cargar();
		centro = new Centro_de_Mensajes();
		ka_sock = new ClientKeepAliveSocket(centro);
	}

	private class InterfazGrafica implements Runnable {
		public void run() {
			
			try {
				UIManager.setLookAndFeel(new SubstanceBusinessBlueSteelLookAndFeel());
			} catch (Exception e) {
				System.out.println("Substance Graphite failed to initialize");
			}
			
			Ventana_Ppal vp = new Ventana_Ppal(centro, ka_sock);
			vp.setVisible(true);
		}
	}

	public static void main(String[] args) {

		// -splash:img/mainbanner.png (en run configurations, como 
		// para para la VM)
		
		/*
		try {
			SwingUtilities.invokeAndWait(new SpScreen());
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		*/
		
		MainChacra main_chacra = new MainChacra();

		// Interfaz grafica
		SwingUtilities.invokeLater(main_chacra.new InterfazGrafica());
		
	}
}
